package com.kb.design.controller;

import com.kb.design.common.ApiResponse;
import com.kb.design.common.ResponseObject;
import com.kb.design.dto.BonusAllocationDTO;
import com.kb.design.dto.ProjectReview;
import com.kb.design.dto.TaskSplittingDTO;
import com.kb.design.entity.DesignDaily;
import com.kb.design.entity.ProjectQaValue;
import com.kb.design.service.DailyService;
import com.kb.design.service.IBonusAllocationService;
import com.kb.design.service.ProjectQaValueService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;;
import java.util.List;
import java.util.Map;

/**
 * @Auther:chenzx
 * @Date:2024-04-03
 * @Description:
 */
@RestController
@RequestMapping("common")
public class CommonController {

    @Resource
    private DailyService dailyService;
    @Resource
     private IBonusAllocationService  bonusAllocationService;
    @Resource
     private ProjectQaValueService qaValueService;

    /**
     * 新增数据
     *
     * @param
     * @return 新增日报
     */
//    @PostMapping("/addDaily")
//    public ApiResponse addDaily(@RequestBody AddDailyDTO addDailyDTO) {
//        dailyService.dailyAdd(addDailyDTO);
//        return ApiResponse.success("保存成功");
//    }
    @PostMapping("/addDaily")
    public ApiResponse addDaily(@RequestBody DesignDaily daily) {
        dailyService.dailyAdd(daily);
        return ApiResponse.success("保存成功");
    }

    /**
     * 日报查询
     * @param daily
     * @return
     */
    @PostMapping("/selectDailyInfo")
    public ApiResponse selectDailyInfo(@RequestBody DesignDaily daily) {
        return ApiResponse.success(dailyService.selectDailyInfo(daily));
    }

    /**
     * 检查
     *
     * @param projectReview
     * @return
     */
    @PostMapping("/qaSave")
    public ApiResponse qaSave(@RequestBody ProjectReview projectReview) {
        return ApiResponse.success(qaValueService.qaSave(projectReview));
    }
    /**
     * 检查保存草稿
     *
     * @param projectReview
     * @return
     */
    @PostMapping("/qaSaveDraft")
    public ApiResponse qaSaveDraft(@RequestBody ProjectReview projectReview) {
        return ApiResponse.success(qaValueService.qaSaveDraft(projectReview));
    }
    /**
     * 检查value
     *
     * @param projectQaValue
     * @return
     */
    @PostMapping("/queryQaValueList")
    public ApiResponse queryQaValueList(@RequestBody ProjectQaValue projectQaValue) {
        ResponseObject responseObject = new ResponseObject();
        List<Map<String, Object>> mapList = qaValueService.queryQaValueList(projectQaValue);
        responseObject.setItems(mapList);
        return ApiResponse.success(responseObject);
    }
    /**
     * 任务拆分
     *
     * @param taskSplittingDTO
     * @return
     */
    @PostMapping("/taskSplitting")
    public ApiResponse taskSplitting(@RequestBody TaskSplittingDTO taskSplittingDTO) {
        dailyService.taskSplitting(taskSplittingDTO);
        return ApiResponse.success("拆分成功");
    }

    /**
     * 新增奖金配置
     *
     * @param
     * @return
     */
    @PostMapping("/addBonusAllocation")
    public ApiResponse addBonusAllocation(@RequestBody BonusAllocationDTO bonusAllocationDTO) {
        bonusAllocationService.saveBonusAllocation(bonusAllocationDTO);
        return ApiResponse.success("保存成功");
    }
    /**
     * 查询奖金配置
     *
     * @param
     * @return
     */
    @PostMapping("/getBonusAllocation")
    public ApiResponse getBonusAllocation(@RequestBody BonusAllocationDTO bonusAllocationDTO) {
        return ApiResponse.success(bonusAllocationService.getBonusAllocation(bonusAllocationDTO));
    }

}
